#include "http-content-type.h"

#include <map>

namespace http
{

static const ContentType g_emptyType("");

static const std::map<std::string_view, ContentType> g_extToType{
    {"js", {"application/x-javascript"}},
    {"css", {"text/css"}},
    {"png", {"image/png"}},
    {"svg", {"image/svg+xml"}},
};

const ContentType &ContentType::fromExt(const std::string_view &ext) {
    auto it = g_extToType.find(ext);
    if (it != g_extToType.end()) {
        return it->second;
    } else {
        return g_emptyType;
    }
}

} // namespace http
